home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / Apple Guide / Engineering / Context Check Modules / Standard CC Modules / Utility.h < prev   
Encoding:
Text File  |  1994-04-25  |  4.6 KB  |  131 lines  |  [TEXT/MPS ]

  1.  
  2. //____________________________________________________________________________________________________
  3. //
  4. //    Copyright:    © 1993 Apple Computer, Inc. All rights reserved.
  5. //
  6. //    Authors:        Scott Searle (original)
  7. //                    Victor J. Hnyp (extensions)
  8. //                    David A. Lyons (DAL)
  9. //
  10. //    Date:            12/01/93
  11. //
  12. // Revisions
  13. //
  14. // 12/01/93 DAL    3.01    Removed address stripping from MY_GET_TRAP_ADDRESS macro.
  15. //                                It's important NOT to strip the old trap addresses, because
  16. //                                ROM routines are at $40xxxxxx even in 24-bit mode, and there
  17. //                                are come-from patches in the system that assume that (like
  18. //                                the window-positioning patch, where GetResource sees that it
  19. //                                it is being called from GetNewDialog).
  20. //
  21. //    02/08/93    VJH    2.03    Changes to the way GetNextItemAddress works
  22. //
  23. //    01/18/93    VJH    2.02    Added:    N2S and GetNextItemAddress
  24. //
  25. //    01/04/93    VJH    2.01    Changed Copyright Notice, added new functions
  26. //
  27. //    22-May-92    1.0d1e1    Changed StringCompareMethod from short to long.
  28. //
  29. //____________________________________________________________________________________________________
  30.  
  31. #ifndef __UTILITY__
  32. #define __UTILITY__
  33.  
  34. //    GENERAL THINGS    •••••••••••••••••••••••••••••••••••••••••••••
  35.  
  36. #define    NumToolboxTraps            ((NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E, ToolTrap)) ? 0x200 : 0x400)
  37. #define    TrapMask                        0x0800
  38. #define    GetTrapType(_theTrap)    (((_theTrap) & TrapMask) ? ToolTrap : OSTrap)
  39.  
  40. #define    GESTALT_BIT_TEST(_sel, _res, _bit)        ((Boolean)(Gestalt((_sel), &(_res)) == noErr && ((_res) >> (_bit)) & 0x00000001))
  41. #define    GESTALT_COMPARE(_sel, _res, _op, _tst)    ((Boolean)(Gestalt((_sel), &(_res)) == noErr && ((short)(_res) _op (short)(_tst))))
  42.  
  43. #define    MY_STRIP_PTR(_p)                                ((void *)  StripAddress((Ptr)(_p)))
  44. #define    MY_STRIP_HDL(_h)                                ((void **) StripAddress((Ptr)(_h)))
  45. #define    MY_GET_TRAP_ADDRESS(_tNum)                    (NGetTrapAddress((_tNum), GetTrapType((_tNum))))
  46. #define    MY_SET_TRAP_ADDRESS(_tAddr, _tNum)        (NSetTrapAddress((long)MY_STRIP_PTR((_tAddr)), (_tNum), GetTrapType((_tNum))))
  47.  
  48. #define    MY_H_OPEN_RES_FILE(_vRefNum, _dirID, _name, _perm)        (HOpenResFile((_vRefNum), (_dirID), MY_STRIP_PTR((_name)), (_perm)))
  49. #define    MY_OPEN_RF_PERM(_name, _wdRefNum, _perm)                    (OpenRFPerm(MY_STRIP_PTR((_name)), (_wdRefNum), (_perm)))
  50.  
  51. enum
  52. {
  53.     commandKeyBit = 48,
  54.     controlKeyBit = 60,
  55.     optionKeyBit,
  56.     alphaLockBit,
  57.     shiftKeyBit
  58. };
  59.  
  60. #define    MBarHeight        (*(short *)(0xBAA))
  61. #define    WindowList        (*(WindowPtr*)0x9D6)
  62. #define    CurrentA5        (*(Ptr **)0x904)
  63. #define    thePort            (*(GrafPtr*)*CurrentA5)
  64. #define    screenBits        ((BitMap *)(*CurrentA5+0xFFFFFF86))
  65. #define    dkGray            ((Pattern*)(*CurrentA5 - 40))
  66. #define    gray                ((Pattern*)(*CurrentA5 - 24))
  67. #define    black                ((Pattern*)(*CurrentA5 - 16))
  68. #define    ltGray            ((Pattern*)((char*)gray - 8))
  69. #define    MCenterR(_r)    (OffsetRect((_r), (screenBits->bounds.right - (_r)->right - (_r)->left) >> 1, \
  70.                                     ((screenBits->bounds.bottom - (_r)->bottom - (_r)->top) >> 1) + 10))
  71. #define    NIL                ((void *)0L)
  72. #define    C_PORT            (0xC000)
  73. #define    HILITE_RGB        ((RGBColor*)0xDA0)
  74. #define    CacheCom            (*(unsigned char *)0x39C)
  75. #define    DAStrings        (*(Handle *)0xAA0)
  76. #define    CurApName        ((unsigned char*)0x910)
  77. #define    CurApRefNum        (*(short*)0x900)
  78. #define    CUR_TIME            (*(unsigned long*)0x20C)
  79. #define    FINDER_NAME        ((char*)0x2E0)
  80. #define    CurDirStore        (*(long *)(0x398))
  81. #define    SFSaveDisk        (*(short *)(0x214))
  82. #define    MenuList            (*(Handle*)0xA1C)
  83.  
  84. #define    true                ((char)1)
  85. #define    false                ((char)0)
  86.  
  87. #define    kEnter            (0x03)
  88. #define    kReturn            (0x0D)
  89. #define    kTab                (0x09)
  90. #define    kESC                (0x1B)
  91. #define    kUpArrow            (0x1E)
  92. #define    kDownArrow        (0x1F)
  93. #define    kLeftArrow        (0x1C)
  94. #define    kRightArrow        (0x1D)
  95. #define    kBackspace        (0x08)
  96. #define    kHelp                (0x05)
  97. #define    kDelete            (0x7F)
  98. #define    kHome                (0x01)
  99. #define    kEnd                (0x04)
  100. #define    kPgUp                (0x0B)
  101. #define    kPgDown            (0x0C)
  102.  
  103. #define    ioDirFlg            (0x10)
  104. #define    TopMapHndl        (*(Handle *)0xA50)        /*    1st map in resource list [Handle] */
  105. #define    HIWORD(aLong)    ((short)(((aLong) >> 16) & 0xFFFF))
  106. #define    LOWORD(aLong)    ((short)((aLong) & 0xFFFF))
  107.  
  108. #define SETRECT(rectp, _left, _top, _right, _bottom)    \
  109.     ((rectp)->left = ((short)(_left)), (rectp)->top = ((short)(_top)),     \
  110.     (rectp)->right = ((short)(_right)), (rectp)->bottom = ((short)(_bottom)))
  111.     
  112. #define INSETRECT(rectp, _dh, _dv)    \
  113.     ((rectp)->left += ((short)(_dh)), (rectp)->top += ((short)(_dv)),     \
  114.     (rectp)->right -= ((short)(_dh)), (rectp)->bottom -= ((short)(_dv)))
  115.     
  116. #define SETPT(pt, _h, _v)            ((pt)->h = (_h), (pt)->v = (_v))
  117.  
  118.  
  119.  
  120. //    •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  121.  
  122. typedef    long    StringCompareMethod;
  123.  
  124. typedef struct
  125. {
  126.     StringCompareMethod        method;
  127.     Str255                        str;
  128. } StringSpec, *StringSpecPtr, **StringSpecHdl;
  129.  
  130. #endif
  131.